//HouseEnvDemoScene.h
//Created 16/05/14
//Created By Daniel Bowler
//
//This scene demonstrates A) model loading (.obj => Static models) and B) Environement
//mapping of the skydome. We will render a number of teapots to demonstrates this effect. 

#pragma once

//This scene is a standard scene and inherits from AbstractScene
//so it will work with our current scene management system
#include "AbstractScene.h"

//Number of point/spot lights. 
#define HOUSE_DEMO_SCENE_ENV_NUM_LIGHTS 100

//Number of teapots (Each will be rendered differntly). 
#define HOUSE_DEMO_SCENE_ENV_NUM_TEAPOTS 1

//MSAA State for this scene? Comment to turn it off, uncomment to turn on.
#define HOUSE_DEMO_SCENE_ENV_SCENE_ENABLE_MSAA

//Forward declare the advanced models we use. 
class SkyDome;

class HouseEnvDemoScene : public AbstractScene
{
public: 
	//Constructor and Destructor. Constructor will be used
	//to init the classes variables (and any pointers to NULL) but leave
	//dynamic allocation to the InitDynamicData() - unless absolutly required
	HouseEnvDemoScene();
	~HouseEnvDemoScene();

	//Override the init and dealloc functions
	void OpenScene();
	void CloseScene();

	//Override the mouse input functions
	void OnMouseDown(WPARAM btnState, int x, int y, UINT originalMessage);
	void OnMouseUp(WPARAM btnState, int x, int y, UINT originalMessage);
	void OnMouseMove(WPARAM btnState, int x, int y);

	//Override OnResize function. 
	void OnResize();

	//Override the render and update functions
	void UpdateWithDelta(float delta);
	void RenderScene();

private:
	//Scene States.
	enum SceneState 
	{ 
		SCENE_STATE_DRAW_SCENE,						//Draws as usual
		SCENE_STATE_DRAW_Z_PRE_PASS_DEPTH_BUFFER,   //Draws depth buffer as full screen quad.
		SCENE_STATE_DRAW_CS_MAX_Z_DEPTH_BUFFER,     //(Optional) Draws tile max z Buffer.
		SCENE_STATE_DRAW_CS_LLSEB_GREYSCALE,		//Visualise how many lights affect a tile. 
		SCENE_STATE_DRAW_CS_LLSEB_COLOUR,           //As above, but with more colour.
		SCENE_STATE_DRAW_CS_LLSEBT_GREYSCALE,       //Transparant tiles - greyscale.
		SCENE_STATE_DRAW_CS_LLSEBT_COLOUR,			//Transparant tiles - colour
		SCENE_STATE_DRAW_SSAO_VIEW_NORMALS,			//Draws view space normal tex (SSAO)
		SCENE_STATE_DRAW_SSAO_VIEW_DEPTHS,			//Draws view space depths (SSAO)
		SCENE_STATE_DRAW_SSAO_MAP,					//Draws SSAOMap.   
		SCENE_STATE_DRAW_SHADOW_DEPTH,				//Draws shadow map DSV 
	};

private:
	//Scene State - what to render?
	SceneState sceneState;

	//Should render lights?
	bool shouldRenderLights;

private:
	//Direc light
	DirectionalLight dLight;

private:
	//SkyDome
	SkyDome* skyDome;

private:
	//Teapot model
	StaticModel* teapot[HOUSE_DEMO_SCENE_ENV_NUM_TEAPOTS];

private:
	//Load the our game models. 
	void LoadModels();

	//Load the SkyDome (and set)
	void LoadSkyDome();

private:
	//Load initial lighting data (point, spot)
	void InitLighting();
	//Init Direc light
	void InitDirecLight();
	//Inits hemispherial ambient light
	void InitHemisphericalAmbientLight();

private:
	//Loads teapot. 
	void LoadTeapot();
};